package com.hzsoft.util;

import java.util.Set;
import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;



public class SetUtil {

	/**
	 * Set集合转换为List
	 * 自然排序
	 */
	public static List<String> setToList(Set<String> parSet) {
		List<String> temp = new ArrayList<String>();
		for (String field : parSet) {
			temp.add(field);
		}
		Collections.sort(temp);
		return temp;
	}
	
	/**
	 * 清除List中的重复String
	 * 自然排序
	 */
	public static List<String> clearList(List<String> parList) {
		List<String> dataList = new ArrayList<String>();
		Set<String> set = new HashSet<String>();
		for (String field : parList) {
			set.add(field);
		}
		for (String d : set) {
			dataList.add(d);
		}
		Collections.sort(dataList);
		return dataList;
	}
	
	public static void main(String[] args) {
		List<String> list = new ArrayList<String>();
		list.add("222");
		list.add("111");
		list.add("333");
		list.add("222");
		list = SetUtil.clearList(list);
		for (String field : list) {
			System.out.println(field);
		}
	}
	
}

